//minxins.js 文件
export default {
    data() {
        return {
            lineForm: {
                videoUrl: null,
                cousName: '',
                img: 'https://yhykt.oss-cn-beijing.aliyuncs.com/9524E6E1F7FD4665ACE117D5BA7F73386.jpg?Expires=4765415777&OSSAccessKeyId=LTAI4Fgsq7J3XQi7e2SRfzjJ&Signature=XWRT8RHs2GV4gCfy1SkE0N%2FrYu4%3D',
                cont: '',
                date: '',
                timeValue: ['12:00', '13:00'],
                certId: '',
                type:2,
                serial:'',
                fileName:''
            },
            TiLength: 0,
            certlist: [],
            lineFormRules: {
                cousName: [{
                    required: true,
                    message: '请输入课程名称',
                    trigger: 'blur'
                }, ],
                date: [{
                    type: 'string',
                    required: true,
                    message: '请选择日期',
                    trigger: 'change'
                }],
                certId: [{
                    required: true,
                    message: '请选择打卡证书模板',
                    trigger: 'blur'
                }],
                // videoUrl: [{
                //     required: true,
                //     message: '请上传视频',
                //     trigger: 'blur'
                // }],
            },
            progInt: 0, // 动态显示进度条
            showProgress: false,
            uploadfileurlVideo: this.$url.baseURL + '/upload/uploadfile',
            images: [{
                    url: 'https://yhykt.oss-cn-beijing.aliyuncs.com/9524E6E1F7FD4665ACE117D5BA7F73386.jpg?Expires=4765415777&OSSAccessKeyId=LTAI4Fgsq7J3XQi7e2SRfzjJ&Signature=XWRT8RHs2GV4gCfy1SkE0N%2FrYu4%3D'
                },
                {
                    url: 'https://yhykt.oss-cn-beijing.aliyuncs.com/A88B376A2CA845F89AE50CA768EAF5C35.jpg?Expires=4765415773&OSSAccessKeyId=LTAI4Fgsq7J3XQi7e2SRfzjJ&Signature=u20iRcxFduqU8myj4yz1Df2dQxQ%3D'
                },
                {
                    url: 'https://yhykt.oss-cn-beijing.aliyuncs.com/76DC365A2B124D06B4CC9F943BA3231D4.jpg?Expires=4765415770&OSSAccessKeyId=LTAI4Fgsq7J3XQi7e2SRfzjJ&Signature=dP3B%2Bp08fnZa91NKn7mNkFOlFus%3D'
                },
                {
                    url: 'https://yhykt.oss-cn-beijing.aliyuncs.com/C03F4B4A119849219B13358A8EDAE3523.jpg?Expires=4765415767&OSSAccessKeyId=LTAI4Fgsq7J3XQi7e2SRfzjJ&Signature=3zQTU2b0X%2FaPmyz0afkBfm4yr5o%3D'
                },
                {
                    url: 'https://yhykt.oss-cn-beijing.aliyuncs.com/68E4F5BEBB6941E494D987C873C1FD062.jpg?Expires=4765415764&OSSAccessKeyId=LTAI4Fgsq7J3XQi7e2SRfzjJ&Signature=o5p%2Ff7K7odsTjSGdLoAZEM8V1AA%3D'
                },
                {
                    url: 'https://yhykt.oss-cn-beijing.aliyuncs.com/7AA2635CC8EB444181F60FBE5C8227B41.jpg?Expires=4765415739&OSSAccessKeyId=LTAI4Fgsq7J3XQi7e2SRfzjJ&Signature=h%2Fc1JFMBhWQpPEYBAv1Ah2jd82M%3D'
                },
                {
                    url: 'https://yhykt.oss-cn-beijing.aliyuncs.com/B9F551F0CD554BEFBA4A647AA495B91613.jpg?Expires=4765415796&OSSAccessKeyId=LTAI4Fgsq7J3XQi7e2SRfzjJ&Signature=naMn8ws9%2Fra1yPpJJLpUawbUM%2BQ%3D'
                },
                {
                    url: 'https://yhykt.oss-cn-beijing.aliyuncs.com/D6CF6B0891A94CBAB5751A1541E8767F12.jpg?Expires=4765415794&OSSAccessKeyId=LTAI4Fgsq7J3XQi7e2SRfzjJ&Signature=OEJCKjm84TVo00wdFrcBvpU28fA%3D'
                },
                {
                    url: 'https://yhykt.oss-cn-beijing.aliyuncs.com/96336BD841E745298075364F0FBEE80F11.jpg?Expires=4765415791&OSSAccessKeyId=LTAI4Fgsq7J3XQi7e2SRfzjJ&Signature=zGx1dRyeQZhBRUXJE%2BBDfWmIx3o%3D'
                },
                {
                    url: 'https://yhykt.oss-cn-beijing.aliyuncs.com/E8D45861416346CD83681853F4EDFF9310.jpg?Expires=4765415788&OSSAccessKeyId=LTAI4Fgsq7J3XQi7e2SRfzjJ&Signature=UsKGMp5t9QCexDVV163JSsAq65U%3D'
                },
                {
                    url: 'https://yhykt.oss-cn-beijing.aliyuncs.com/D0BDEE29A8A645B1ADC928CD3E9FDC879.jpg?Expires=4765415785&OSSAccessKeyId=LTAI4Fgsq7J3XQi7e2SRfzjJ&Signature=frmz9hZDpBwpc3ff3o0EAvgUN2c%3D'
                },
                {
                    url: 'https://yhykt.oss-cn-beijing.aliyuncs.com/0C50AFC888C640E2A6C1DECEC7D2CFE38.jpg?Expires=4765415783&OSSAccessKeyId=LTAI4Fgsq7J3XQi7e2SRfzjJ&Signature=V9QO8tMwft1c8qA2ozgKRkvV0Cg%3D'
                },
                {
                    url: 'https://yhykt.oss-cn-beijing.aliyuncs.com/3B242A2BF59A4DADAFE7F6FCB07A2CE87.jpg?Expires=4765415780&OSSAccessKeyId=LTAI4Fgsq7J3XQi7e2SRfzjJ&Signature=oDL9EME6gPs%2BUBKTaikjXkso7IA%3D'
                },
            ],
        }
    },
    created() {},
    methods: {
        resetForm() {
            console.log('chushihua');
            // this.$refs.lineForm.resetFields();
            this.lineForm ={
                videoUrl: null,
                cousName: '',
                img: 'https://yhykt.oss-cn-beijing.aliyuncs.com/9524E6E1F7FD4665ACE117D5BA7F73386.jpg?Expires=4765415777&OSSAccessKeyId=LTAI4Fgsq7J3XQi7e2SRfzjJ&Signature=XWRT8RHs2GV4gCfy1SkE0N%2FrYu4%3D',
                cont: '',
                date: '',
                timeValue: ['12:00', '13:00'],
                certId: '',
                type:2,
                serial:''
            }
        },
        progressVideo(event) {
            this.showProgress = true;
            this.progInt = parseInt(event.loaded / event.total * 100, 10);

            // this.loadProgress = parseInt(event.percent); // 动态获取文件上传进度
            // if (this.loadProgress >= 100) {
            //     this.loadProgress = 100
            //     setTimeout(() => {
            //         this.progressFlag = false
            //     }, 1000) // 一秒后关闭进度条
            // }
        },
        successVideo(response, file, fileList) {
            console.log(response);
            this.showProgress = false;
            this.lineForm.osskey = response.osskey;
            this.lineForm.fileName = file.name;
            this.lineForm.fileid = response.body.data.fileid;
            this.lineForm.videoUrl = response.body.data.url;
            this.$refs['url'].clearValidate()
        },
        beforeUploadVideo(file) {
            const fileName = file.name;
            const index = fileName.lastIndexOf(".");
            const ext = fileName.substr(index + 1);
            const arr = ["mp4"];
            const isOk = arr.includes(ext);
            if (!isOk) {
                this.$message.warning('视频格式暂不支持！');
                return false;
            }
            var imgSize = file.size / (1024 * 1024);
            if (imgSize > 1024) {
                this.$message.warning(`当前文件${ parseInt(imgSize) }M,上传文件不能超过1G`)
                return false
            }
        },


    }
}
